package service

import (
	"errors"
	"quant/backend/constants"

	"github.com/wailsapp/wails/v3/pkg/application"
)

type User struct {
	Name string
	Age  int
}

type GreetService struct{}

func NewGreetService() *GreetService {
	return &GreetService{}
}

func (g *GreetService) Greet(name string) string {
	return "Hello " + name + "!"
}

func (g *GreetService) GetUserList() []User {
	var users = []User{
		{"John", 20},
		{"Jane", 21},
	}
	return users
}

func (g *GreetService) GetError() (User, error) {
	return User{
		Name: "Leehuajun",
		Age:  20,
	}, errors.New("自定义错误")
}
func (g *GreetService) OpenDialog(t string) {
	var dialog *application.MessageDialog
	if t == "info" {
		dialog = constants.App.Dialog.Info()
	} else if t == "warn" {
		dialog = constants.App.Dialog.Warning()
	} else if t == "error" {
		dialog = constants.App.Dialog.Error()
	} else if t == "question" {
		dialog = constants.App.Dialog.Question()
	} else {
		dialog = constants.App.Dialog.Info()
	}
	dialog.Title = "自定义标题"
	dialog.Message = "自定义内容"
	dialog.Show()
}
